package com.blb.ioc;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ComputerDemo2 {

    public static void main(String[] args) {
        //创建ClassPath应用程序上下文
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("spring01.xml");
        //从容器中获得对象 通过对象名
//        Computer computer = (Computer) context.getBean("computer");
        //通过类型
        Computer computer = context.getBean(Computer.class);
        computer.start();

        Computer computer1 = context.getBean(Computer.class);
        System.out.println(computer == computer1);
    }
}
